package com.vent.mirai;

import com.vent.mirai.events.GroupEvent;
import com.vent.share.service.ShareService;
import lombok.extern.slf4j.Slf4j;
import net.mamoe.mirai.Bot;
import net.mamoe.mirai.BotFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Description: Mirai 相关逻辑
 *
 * @author ZiXiu
 * @date 2021/8/19 17:17
 */
@Slf4j
@Service
public class MiraiService {

    private GroupEvent groupEvent;

    public MiraiService(GroupEvent groupEvent) {
        this.groupEvent = groupEvent;
    }

    /**
     * 启动Mirai
     */
    public void startMirai() {
        Bot bot = BotFactory.INSTANCE.newBot(1L, "123465");
        bot.login();
        //输出好友
        bot.getFriends().forEach(friend -> log.info(friend.getId() + ":" + friend.getNick()));
        bot.getEventChannel().registerListenerHost(groupEvent);
        log.info("============>> Mirai启动完成！");
    }

}
